package org.apache.flink.runtime.rest.messages;

import org.apache.flink.runtime.rest.HttpMethodWrapper;
import org.apache.flink.runtime.rest.handler.job.ConsumCancellationHandler;

import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;

/** Message headers for the {@link ConsumCancellationHandler}. */
public class ConsumingCancellationHeaders
        implements RuntimeMessageHeaders<
                EmptyRequestBody, EmptyResponseBody, JobCancellationMessageParameters> {

    public static final String URL = "/jobs/:jobid";

    private static final ConsumingCancellationHeaders INSTANCE = new ConsumingCancellationHeaders();

    private ConsumingCancellationHeaders() {}

    @Override
    public Class<EmptyRequestBody> getRequestClass() {
        return EmptyRequestBody.class;
    }

    @Override
    public Class<EmptyResponseBody> getResponseClass() {
        return EmptyResponseBody.class;
    }

    @Override
    public HttpResponseStatus getResponseStatusCode() {
        return HttpResponseStatus.ACCEPTED;
    }

    @Override
    public JobCancellationMessageParameters getUnresolvedMessageParameters() {
        return new JobCancellationMessageParameters();
    }

    @Override
    public HttpMethodWrapper getHttpMethod() {
        return HttpMethodWrapper.PATCH;
    }

    @Override
    public String getTargetRestEndpointURL() {
        return URL;
    }

    public static ConsumingCancellationHeaders getInstance() {
        return INSTANCE;
    }

    @Override
    public String getDescription() {
        return "Terminates a job.";
    }

    @Override
    public String operationId() {
        return "cancelJob";
    }
}
